<?php
/**
 * Created by PhpStorm.
 * User: HLG
 * Date: 2019/10/14
 * Time: 17:28
 */
namespace app\api\validate;
use think\Validate;

class Address extends Validate
{
    /**
     * 验证规则
     * @var array
     */
    protected $rule = [

        // 用户手机号
        'mobile' => 'require|number|min:11|max:11',
        'name' => 'require',
        'province_id' => 'require|number',
        'city_id' => 'require|number',
        'region_id' => 'require|number',
        'detail' => 'require',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名'    => '错误信息'
     *
     * @var array
     */
    protected $message = [
        'mobile.require'      => '手机号不能为空',
        'mobile.number'    => '手机号只能是数字',
        'mobile.min'      => '手机号最少11位',
        'mobile.max'      => '手机号最大11位',
        'province_id.require'     => '请选择省份',
        'province_id.number'     => '省份值是数字',
        'city_id.require'     => '请选择市区',
        'city_id.number'          => '市区值是数字',
        'name.require'          => '收货人姓名不能为空',
        'region_id.require' => '请选择区县',
        'region_id.number' => '区县值是数字',
        'detail.require' => '请输入详细地址',
    ];
    /**
     * 使用场景
     */
    protected $scene = [
        'register' => ['mobile','password','pay_password','code'],
        'login'  =>  ['mobile','password','pay_password'],
        'authentic' => ['mobile','true_name','idcard'],
    ];

}